#ifndef STRING_H
#define STRING_H
#include <string>
#include <Windows.h>
#include <core/core.h>

namespace Core
{
    class CORE_API String
    {
    public:
        typedef wchar_t Char;
        typedef std::basic_string<Char> StdString;

        String();
        String(const String& s);
        String(const Char* str);
        String(const std::size_t bytesNumber);
        String(const StdString& stdString);

        ~String();

        //makes string empty
        void clear();

        const Char* c_str() const;
        Char* c_str();

        //
        String operator+(const String& s) const;
        String& operator=(const String& s);
        String& operator+=(const String& s);
        bool operator!=(const String& s) const;
        bool operator==(const String& s) const;

        CompareResult compareIgnoringCase(const String& s) const;
        CompareResult compare(const String& s) const;
        void toLowerCase();
        void toUpperCase();
        
        //extracts sub-string
        String substr(const int begin, const int length) const;

        bool empty() const;
        const std::size_t length() const;

        //how many memory reserved
        const std::size_t capacity() const;
        
        //overwrite string
        void assign(const Char* s);
        void assign(const String& s);

        void append(const Char* s);
        void append(const String& s);
    private:
        bool alloc(const std::size_t sz);
        void destroy();
        Char* m_buffer;

        std::size_t m_size;//size of allocated buffer
        std::size_t m_length;//length of the string
    };
}

#endif